package com.gdkm.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.gdkm.po.Prescription;
import com.gdkm.service.PrescriptionService;

@Controller

public class PrescriptionController {
	@Autowired
	PrescriptionService service;
	
	
	@RequestMapping("/prescription")
	public String ss() {
		return "prescription";
		
	}
	
	
	
	@ResponseBody
	@RequestMapping("/list4")
	public List get(int y) {
		List<Prescription> list2 = service.list2((y-1)*8, 8);
		System.out.println(list2.toString());
		return list2;
	}
	@RequestMapping("/psave")
	public String save(String pr_number, String pr_name,String pr_doctor,String pr_method,String pr_type, String total_amount,String fees,String re_fess,String charge_time, String options,String symptom,String yn_charge) {
		service.save1(pr_number, pr_name,pr_name,pr_method,pr_type,total_amount,fees,re_fess,charge_time,options,symptom,yn_charge);
		return "prescription";
		
	}
	
	@ResponseBody
	@RequestMapping("/plist")
	public List get(String pr_number,String pr_name,int y) {
		 
		List<Prescription> list = service.list3(pr_number,pr_name,(y-1)*8, 8);
		System.out.println("模糊"+list);
		return list;
	}
	@RequestMapping("/pdel")
	public String del(int id) {
		service.delete1(id);
		return "prescription";
	}
	//更新
	@RequestMapping("/pupdate")
    public String update(Prescription stu){
        service.update(stu);
        System.out.print(stu);
        return  "prescription";
}

}
